package cn.jzq.kotoba.modules.designpattern.strategy.charge.demo;

import cn.jzq.kotoba.modules.designpattern.strategy.charge.ChargeTypeEnum;

/**
 * 使用 Context 来查看当它改变策略 Strategy 时的行为变化。
 */
public class Context {
 
    private Strategy strategy;
   
    public Double calRecharge(Double charge, Integer type) {
       strategy = StrategyFactory.getInstance().creator(type);
       return strategy.calCharge(charge, ChargeTypeEnum.valueOf(type));
    }
 
    public Strategy getStrategy() {
       return strategy;
    }
 
    public void setStrategy(Strategy strategy) {
       this.strategy = strategy;
    }
   
}